﻿using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action.Terran
{
	public abstract class ActionUpgradeFromFactoryTechLab : ActionUpgradeFromTerran
	{
		public ActionUpgradeFromFactoryTechLab(int researchTime, int minerals, int gas) : base(researchTime, minerals, gas) { }

		public override TerranState.TerranProductionBuilding GetProductionBuilding(TerranState state) { return state.FactoryTechLab; }

		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
				{
					m_Requirements = new IAction[,] { 
						{ ActionProduceTechLabOnFactory.Instance }, 
						{ ActionSwitchTechLabFromBarracksToFactory.Instance }, 
						{ ActionSwitchTechLabFromStarportToFactory.Instance }, 
					};
				}
				return m_Requirements;
			}
		}
	}
	public class ActionUpgradeSiegeTech : ActionUpgradeFromFactoryTechLab
	{
		public static ActionUpgradeSiegeTech Instance = new ActionUpgradeSiegeTech();

		public ActionUpgradeSiegeTech() : base(80, 100, 100) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.SiegeTech; }
		public override string EventName { get { return "ActionResearchedSiegeTech"; } }
	}
	public class ActionUpgradeInfernalPreIgniter : ActionUpgradeFromFactoryTechLab
	{
		public static ActionUpgradeInfernalPreIgniter Instance = new ActionUpgradeInfernalPreIgniter();

		public ActionUpgradeInfernalPreIgniter() : base(110, 150, 150) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.InfernalPreIgniter; }
		public override string EventName { get { return "ActionResearchedInfernalPreIgniter"; } }
	}
	public class ActionUpgradeStrikeCannon : ActionUpgradeFromFactoryTechLab
	{
		public static ActionUpgradeStrikeCannon Instance = new ActionUpgradeStrikeCannon();

		public ActionUpgradeStrikeCannon() : base(110, 150, 150) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.StrikeCannon; }
		public override string EventName { get { return "ActionResearchedStrikeCannon"; } }
		public override bool IsInvalid(IBuildOrder bo)
		{
			TerranState state = bo.State as TerranState;
			return base.IsInvalid(bo) || (state.Armory.Total == 0);
		}
		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
					m_Requirements = new IAction[,] { { ActionProduceArmory.Instance } };
				return m_Requirements;
			}
		}
	}
}
